package com.filmbooks.fragment.mine.child;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.filmbooks.R;
import com.zyw.horrarndoo.sdk.base.activity.BaseCompatActivity;
import com.zyw.horrarndoo.sdk.base.fragment.BaseCompatFragment;
import com.zyw.horrarndoo.sdk.utils.SpUtils;

import butterknife.BindView;
import me.yokeyword.fragmentation.ISupportFragment;

/**
 * Created by heshuxiang on 2018/3/6.
 * 描述：
 * 公司：盟将威
 * 作者：heshuxiang
 * 日期：2018/3/6.
 * 工程：FilmBooks
 * 包：com.filmbooks.fragment.mine.child
 */

public class MineSettingFragment extends BaseCompatFragment {
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.night)
    CheckBox night;

    @Override
    public int getLayoutId() {
        return R.layout.mine_setting_;
    }

    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {
        toolbar.setNavigationIcon(R.mipmap.ic_arrow_back_white);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onBackPressedSupport();
            }
        });
        boolean isNight = SpUtils.getNightModel(mContext);
        night.setChecked(isNight);
        night.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                SpUtils.setNightModel(mContext, b);
                night.setChecked(b);
                ((BaseCompatActivity) mActivity).reload();

            }
        });
    }

    public static ISupportFragment newInstance() {
        Bundle bundle = new Bundle();
        MineSettingFragment fragment = new MineSettingFragment();
        fragment.setArguments(bundle);
        return fragment;
    }
}
